#define _CRT_SECURE_NO_WARNINGS 1
#include <stdio.h>

int main() {
    int arr[21][21] = { 0 };
    int n = 0;
    while (scnaf("%d", &n) != -1) {
        for (int i = 0; i < 21; i++) {
            for (int j = 0; j < 21; j++) {
                arr[i][j] = ' ';
            }
        }
        for (int i = 0; i < n; i++) {
            if (i == 0 || i == n - 1) {
                for (int j = 0; j < n; j++) {
                    arr[i][j] = '*';
                }
            }
            else {
                for (int j = 0; j < n; j++)
                    if (j == 0 || j == n - 1) {
                        arr[i][j] = '*';
                    }

            }
        }
        for (int i = 0; i < n; i++) {
            for (int j = 0; j < n; j++) {
                printf("%c", arr[i][j]);
            }
            printf("\n");
        }
    }


    return 0;
}